package com.zxn.xiaoran;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatDelegate;


import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
import com.scwang.smartrefresh.layout.api.DefaultRefreshInitializer;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.zcommon.lib.UIUtils;
import com.zxn.presenter.BaseApp;
import com.zxn.xiaoran.utils.DynamicTimeFormat;

/**
 * Created by zxn on 2019/5/8.
 */
public class XRApp extends BaseApp {

    static {
        //启用矢量图兼容
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
        //设置全局默认配置（优先级最低，会被其他设置覆盖）
        SmartRefreshLayout.setDefaultRefreshInitializer(new DefaultRefreshInitializer() {
            @Override
            public void initialize(@NonNull Context context, @NonNull RefreshLayout layout) {
                //全局设置（优先级最低）
                layout.setEnableAutoLoadMore(true);
                layout.setEnableOverScrollDrag(false);
                layout.setEnableOverScrollBounce(true);
                layout.setEnableLoadMoreWhenContentNotFull(true);
                layout.setEnableScrollContentWhenRefreshed(true);
            }
        });
        SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
            @NonNull
            @Override
            public RefreshHeader createRefreshHeader(@NonNull Context context, @NonNull RefreshLayout layout) {
                //全局设置主题颜色（优先级第二低，可以覆盖 DefaultRefreshInitializer 的配置，与下面的ClassicsHeader绑定）
                layout.setPrimaryColorsId(R.color.colorPrimary, android.R.color.white);

                return new ClassicsHeader(context).setTimeFormat(new DynamicTimeFormat("更新于 %s"));
            }
        });
    }

    public static XRApp mXMApp;

    @Override
    public void onCreate() {
        super.onCreate();
        mXMApp = this;
        UIUtils.init(this);

        initImagePicker();

    }

    private void initImagePicker() {
//        ImagePicker imagePicker = ImagePicker.getInstance();
//        imagePicker.setImageLoader(new GlidePickerLoader());
//        imagePicker.setShowCamera(false);
//        imagePicker.setCrop(false);
//        imagePicker.setSaveRectangle(true);
//        imagePicker.setSelectLimit(9);
//        imagePicker.setStyle(CropImageView.Style.RECTANGLE);
//        imagePicker.setFocusWidth(800);
//        imagePicker.setFocusHeight(800);
//        imagePicker.setOutPutX(1000);
//        imagePicker.setOutPutY(1000);
//        imagePicker.setMultiMode(false);
    }
}
